﻿using JZ_UDI.DataAccess.DataEntity;
using JZ_UDI.View.Settings;
using System.Data.Entity;

namespace JZ_UDI.DataAccess
{
    public class EFDbContext : DbContext
    {

        public EFDbContext() : base("name=DefaultConnection")
        {

        }


        public DbSet<Product> Products { get; set; }
        public DbSet<User> Users { get; set; }

        public DbSet<VendorCode> VendorCodes { get; set; }
  
        public DbSet<UserPrivilege> UserPrivileges { get; set; }

        public DbSet<PrivilegeList> privilegeLists { get; set; }


        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Product>().ToTable("Product").HasKey(p => p.ID);
            modelBuilder.Entity<User>().ToTable("User").HasKey(p => p.UserName);
            modelBuilder.Entity<VendorCode>().ToTable("VendorCode").HasKey(p => p.Vendor_Code);
            modelBuilder.Entity<UserPrivilege>().ToTable("UserPrivilege").HasKey(p => p.ID);
            modelBuilder.Entity<PrivilegeList>().ToTable("PrivilegeList").HasKey(p => p.ID);
        }
    }
}
